<?php
     //=========================<script réaliser par :MEZOUARI KHALID>===================
       include("verifierSession.php");
       require_once("beans/nomadeBean.php");
       require_once("dao/nomadeDao.php");
       require_once("beans/userBean.php");
       require_once("dao/userDao.php");
       include('connectBD.php');
      extract($_POST);
      $nomade   =new nomadeBean();
      $nomadeDao=new nomadeDao();
      $user=new userBean();
      $userDao=new userDao();
      if(isset($nom) and isset($prenom) and isset($dateNaissance) and isset($fonction) and isset($cin) and isset($login)and isset($newpassword)and isset($oldpassword)){
       $nomade=$nomadeDao->loadNomadeByLogin($login);//pour trouver l idUser
       $nomade->setNom($nom);
       $nomade->setPrenom($prenom);
       $nomade->setDateNaissance($dateNaissance);
       $nomade->setFonction($fonction);
       $nomade->setCIN($cin);
       $nomadeDao->updateNomade($nomade);
       echo"hahowa id kaydouz".$nomade->getIdUser();
       $user->setLogin($login);
       //$user->setLogin($login);
       $user->setPassword($newpassword);
       /*if($newpassword=$oldpassword){*/
        $userDao->updateUser($user);
        $tpl->display("succees.html");
       //}
       

    }
    else{
         
         $nomade=$nomadeDao->loadNomadeByLogin($login);
         $title="modifier profil";
         $page="home";
         $tpl->assign('nomade',$nomade);
         $tpl->assign('title',$title);
         $tpl->assign('page',$page); 
         echo "ana hna" ;
         $tpl->display("modifierProfil.html");
}
?>